library(tidyverse) # Manipulation des données
library(readxl) # Lecture des fichiers Excel
library(ggpubr) # Représentations graphiques
library(rstatix) # Tests statistiques en langage Dplyr
library(FactoMineR) # Analyses en composantes principales
library(factoextra) # Visualisation graphique de l'ACP
library(gtsummary) # Résumé descriptif des données
library(corrplot)
library(plotly)
data <- read_excel("data/data_ubs.xlsx", sheet = "reponses") %>% select(-ID)
head(data)
| Characteristic | N = 1821 |
|---|---|
| LDS2 | |
| Â Â Â Â 1 | 7 (3.8%) |
| Â Â Â Â 2 | 12 (6.6%) |
| Â Â Â Â 3 | 46 (25%) |
| Â Â Â Â 4 | 79 (43%) |
| Â Â Â Â 5 | 38 (21%) |
| LDS3 | |
| Â Â Â Â 1 | 3 (1.6%) |
| Â Â Â Â 2 | 12 (6.6%) |
| Â Â Â Â 3 | 122 (67%) |
| Â Â Â Â 4 | 35 (19%) |
| Â Â Â Â 5 | 10 (5.5%) |
| LDS4 | |
| Â Â Â Â 1 | 7 (3.8%) |
| Â Â Â Â 2 | 19 (10%) |
| Â Â Â Â 3 | 95 (52%) |
| Â Â Â Â 4 | 49 (27%) |
| Â Â Â Â 5 | 12 (6.6%) |
| LDS5 | |
| Â Â Â Â 1 | 5 (2.7%) |
| Â Â Â Â 2 | 27 (15%) |
| Â Â Â Â 3 | 62 (34%) |
| Â Â Â Â 4 | 57 (31%) |
| Â Â Â Â 5 | 31 (17%) |
| LDS6 | |
| Â Â Â Â 1 | 28 (15%) |
| Â Â Â Â 2 | 41 (23%) |
| Â Â Â Â 3 | 69 (38%) |
| Â Â Â Â 4 | 37 (20%) |
| Â Â Â Â 5 | 7 (3.8%) |
| NSUB1 | |
| Â Â Â Â 1 | 3 (1.6%) |
| Â Â Â Â 2 | 4 (2.2%) |
| Â Â Â Â 3 | 75 (41%) |
| Â Â Â Â 4 | 72 (40%) |
| Â Â Â Â 5 | 28 (15%) |
| NSUB2 | |
| Â Â Â Â 1 | 21 (12%) |
| Â Â Â Â 2 | 58 (32%) |
| Â Â Â Â 3 | 84 (46%) |
| Â Â Â Â 4 | 16 (8.8%) |
| Â Â Â Â 5 | 3 (1.6%) |
| NSUB3 | |
| Â Â Â Â 1 | 39 (21%) |
| Â Â Â Â 2 | 59 (32%) |
| Â Â Â Â 3 | 45 (25%) |
| Â Â Â Â 4 | 31 (17%) |
| Â Â Â Â 5 | 8 (4.4%) |
| NSUB4 | |
| Â Â Â Â 1 | 20 (11%) |
| Â Â Â Â 2 | 29 (16%) |
| Â Â Â Â 3 | 47 (26%) |
| Â Â Â Â 4 | 57 (31%) |
| Â Â Â Â 5 | 29 (16%) |
| NSUB5 | |
| Â Â Â Â 1 | 8 (4.4%) |
| Â Â Â Â 2 | 15 (8.2%) |
| Â Â Â Â 3 | 43 (24%) |
| Â Â Â Â 4 | 70 (38%) |
| Â Â Â Â 5 | 46 (25%) |
| CF1 | |
| Â Â Â Â 1 | 2 (1.1%) |
| Â Â Â Â 2 | 6 (3.3%) |
| Â Â Â Â 3 | 24 (13%) |
| Â Â Â Â 4 | 83 (46%) |
| Â Â Â Â 5 | 67 (37%) |
| CF2 | |
| Â Â Â Â 1 | 14 (7.7%) |
| Â Â Â Â 2 | 49 (27%) |
| Â Â Â Â 3 | 45 (25%) |
| Â Â Â Â 4 | 63 (35%) |
| Â Â Â Â 5 | 11 (6.0%) |
| CF3 | |
| Â Â Â Â 1 | 97 (53%) |
| Â Â Â Â 2 | 54 (30%) |
| Â Â Â Â 3 | 23 (13%) |
| Â Â Â Â 4 | 5 (2.7%) |
| Â Â Â Â 5 | 3 (1.6%) |
| CF4 | |
| Â Â Â Â 1 | 1 (0.5%) |
| Â Â Â Â 2 | 4 (2.2%) |
| Â Â Â Â 3 | 10 (5.5%) |
| Â Â Â Â 4 | 49 (27%) |
| Â Â Â Â 5 | 118 (65%) |
| CF5 | |
| Â Â Â Â 2 | 2 (1.1%) |
| Â Â Â Â 3 | 8 (4.4%) |
| Â Â Â Â 4 | 64 (35%) |
| Â Â Â Â 5 | 108 (59%) |
| CF6 | |
| Â Â Â Â 1 | 5 (2.7%) |
| Â Â Â Â 2 | 16 (8.8%) |
| Â Â Â Â 3 | 65 (36%) |
| Â Â Â Â 4 | 49 (27%) |
| Â Â Â Â 5 | 47 (26%) |
| CF7 | |
| Â Â Â Â 1 | 2 (1.1%) |
| Â Â Â Â 2 | 8 (4.4%) |
| Â Â Â Â 3 | 39 (21%) |
| Â Â Â Â 4 | 84 (46%) |
| Â Â Â Â 5 | 49 (27%) |
| CF8 | |
| Â Â Â Â 1 | 7 (3.8%) |
| Â Â Â Â 2 | 24 (13%) |
| Â Â Â Â 3 | 48 (26%) |
| Â Â Â Â 4 | 79 (43%) |
| Â Â Â Â 5 | 24 (13%) |
| AFE1 | |
| Â Â Â Â 1 | 5 (2.7%) |
| Â Â Â Â 2 | 13 (7.1%) |
| Â Â Â Â 3 | 92 (51%) |
| Â Â Â Â 4 | 39 (21%) |
| Â Â Â Â 5 | 33 (18%) |
| AFE2 | |
| Â Â Â Â 1 | 20 (11%) |
| Â Â Â Â 2 | 40 (22%) |
| Â Â Â Â 3 | 76 (42%) |
| Â Â Â Â 4 | 33 (18%) |
| Â Â Â Â 5 | 13 (7.1%) |
| AFE4 | |
| Â Â Â Â 1 | 9 (4.9%) |
| Â Â Â Â 2 | 16 (8.8%) |
| Â Â Â Â 3 | 28 (15%) |
| Â Â Â Â 4 | 51 (28%) |
| Â Â Â Â 5 | 78 (43%) |
| AFE5 | |
| Â Â Â Â 1 | 7 (3.8%) |
| Â Â Â Â 2 | 25 (14%) |
| Â Â Â Â 3 | 41 (23%) |
| Â Â Â Â 4 | 71 (39%) |
| Â Â Â Â 5 | 38 (21%) |
| APF1 | |
| Â Â Â Â 1 | 3 (1.6%) |
| Â Â Â Â 2 | 14 (7.7%) |
| Â Â Â Â 3 | 92 (51%) |
| Â Â Â Â 4 | 44 (24%) |
| Â Â Â Â 5 | 29 (16%) |
| APF2 | |
| Â Â Â Â 1 | 13 (7.1%) |
| Â Â Â Â 2 | 22 (12%) |
| Â Â Â Â 3 | 86 (47%) |
| Â Â Â Â 4 | 40 (22%) |
| Â Â Â Â 5 | 21 (12%) |
| APF3 | |
| Â Â Â Â 2 | 9 (4.9%) |
| Â Â Â Â 3 | 27 (15%) |
| Â Â Â Â 4 | 62 (34%) |
| Â Â Â Â 5 | 84 (46%) |
| APF4 | |
| Â Â Â Â 2 | 3 (1.6%) |
| Â Â Â Â 3 | 11 (6.0%) |
| Â Â Â Â 4 | 66 (36%) |
| Â Â Â Â 5 | 102 (56%) |
| APF5 | |
| Â Â Â Â 1 | 1 (0.5%) |
| Â Â Â Â 2 | 4 (2.2%) |
| Â Â Â Â 3 | 19 (10%) |
| Â Â Â Â 4 | 52 (29%) |
| Â Â Â Â 5 | 106 (58%) |
| APF6 | |
| Â Â Â Â 1 | 3 (1.6%) |
| Â Â Â Â 2 | 13 (7.1%) |
| Â Â Â Â 3 | 89 (49%) |
| Â Â Â Â 4 | 55 (30%) |
| Â Â Â Â 5 | 22 (12%) |
| IEIP1 | |
| Â Â Â Â 2 | 1 (0.5%) |
| Â Â Â Â 3 | 5 (2.7%) |
| Â Â Â Â 4 | 86 (47%) |
| Â Â Â Â 5 | 90 (49%) |
| IEIP2 | |
| Â Â Â Â 1 | 2 (1.1%) |
| Â Â Â Â 2 | 6 (3.3%) |
| Â Â Â Â 3 | 12 (6.6%) |
| Â Â Â Â 4 | 52 (29%) |
| Â Â Â Â 5 | 110 (60%) |
| IEIP3 | |
| Â Â Â Â 1 | 2 (1.1%) |
| Â Â Â Â 2 | 14 (7.7%) |
| Â Â Â Â 3 | 33 (18%) |
| Â Â Â Â 4 | 70 (38%) |
| Â Â Â Â 5 | 63 (35%) |
| IEIP4 | |
| Â Â Â Â 1 | 36 (20%) |
| Â Â Â Â 2 | 56 (31%) |
| Â Â Â Â 3 | 51 (28%) |
| Â Â Â Â 4 | 21 (12%) |
| Â Â Â Â 5 | 18 (9.9%) |
| MOT1 | |
| Â Â Â Â 1 | 2 (1.1%) |
| Â Â Â Â 2 | 15 (8.2%) |
| Â Â Â Â 3 | 85 (47%) |
| Â Â Â Â 4 | 54 (30%) |
| Â Â Â Â 5 | 26 (14%) |
| MOT2 | |
| Â Â Â Â 1 | 1 (0.5%) |
| Â Â Â Â 2 | 3 (1.6%) |
| Â Â Â Â 3 | 19 (10%) |
| Â Â Â Â 4 | 106 (58%) |
| Â Â Â Â 5 | 53 (29%) |
| MOT3 | |
| Â Â Â Â 2 | 4 (2.2%) |
| Â Â Â Â 3 | 7 (3.8%) |
| Â Â Â Â 4 | 91 (50%) |
| Â Â Â Â 5 | 80 (44%) |
| MOT4 | |
| Â Â Â Â 1 | 6 (3.3%) |
| Â Â Â Â 2 | 19 (10%) |
| Â Â Â Â 3 | 73 (40%) |
| Â Â Â Â 4 | 55 (30%) |
| Â Â Â Â 5 | 29 (16%) |
| MOT5 | |
| Â Â Â Â 2 | 7 (3.8%) |
| Â Â Â Â 3 | 41 (23%) |
| Â Â Â Â 4 | 88 (48%) |
| Â Â Â Â 5 | 46 (25%) |
| MOT6 | |
| Â Â Â Â 1 | 2 (1.1%) |
| Â Â Â Â 3 | 4 (2.2%) |
| Â Â Â Â 4 | 47 (26%) |
| Â Â Â Â 5 | 129 (71%) |
| MOT7 | |
| Â Â Â Â 2 | 1 (0.5%) |
| Â Â Â Â 3 | 16 (8.8%) |
| Â Â Â Â 4 | 84 (46%) |
| Â Â Â Â 5 | 81 (45%) |
| MOT8 | |
| Â Â Â Â 2 | 1 (0.5%) |
| Â Â Â Â 3 | 2 (1.1%) |
| Â Â Â Â 4 | 53 (29%) |
| Â Â Â Â 5 | 126 (69%) |
| MOT9 | |
| Â Â Â Â 1 | 5 (2.7%) |
| Â Â Â Â 2 | 3 (1.6%) |
| Â Â Â Â 3 | 29 (16%) |
| Â Â Â Â 4 | 71 (39%) |
| Â Â Â Â 5 | 74 (41%) |
| INTU1 | |
| Â Â Â Â 1 | 4 (2.2%) |
| Â Â Â Â 2 | 6 (3.3%) |
| Â Â Â Â 3 | 39 (21%) |
| Â Â Â Â 4 | 77 (42%) |
| Â Â Â Â 5 | 56 (31%) |
| 1 n (%) | |
res.pca <- PCA(data, scale.unit = T, graph = F)
print(res.pca)
**Results for the Principal Component Analysis (PCA)**
The analysis was performed on 182 individuals, described by 42 variables
*The results are available in the following objects:
name description
1 "$eig" "eigenvalues"
2 "$var" "results for the variables"
3 "$var$coord" "coord. for the variables"
4 "$var$cor" "correlations variables - dimensions"
5 "$var$cos2" "cos2 for the variables"
6 "$var$contrib" "contributions of the variables"
7 "$ind" "results for the individuals"
8 "$ind$coord" "coord. for the individuals"
9 "$ind$cos2" "cos2 for the individuals"
10 "$ind$contrib" "contributions of the individuals"
11 "$call" "summary statistics"
12 "$call$centre" "mean of the variables"
13 "$call$ecart.type" "standard error of the variables"
14 "$call$row.w" "weights for the individuals"
15 "$call$col.w" "weights for the variables"
eig.val <- get_eigenvalue(res.pca)
head(eig.val, 30)
eigenvalue variance.percent cumulative.variance.percent
Dim.1 9.2402024 22.0004820 22.00048
Dim.2 2.4639492 5.8665456 27.86703
Dim.3 2.3166215 5.5157656 33.38279
Dim.4 2.1244777 5.0582801 38.44107
Dim.5 1.7006938 4.0492711 42.49034
Dim.6 1.5799665 3.7618251 46.25217
Dim.7 1.5150096 3.6071658 49.85934
Dim.8 1.3376258 3.1848233 53.04416
Dim.9 1.2928697 3.0782611 56.12242
Dim.10 1.1820698 2.8144519 58.93687
Dim.11 1.0698838 2.5473424 61.48421
Dim.12 1.0204833 2.4297221 63.91394
Dim.13 0.9394521 2.2367907 66.15073
Dim.14 0.9333435 2.2222464 68.37297
Dim.15 0.8877470 2.1136834 70.48666
Dim.16 0.8124980 1.9345190 72.42118
Dim.17 0.7878440 1.8758191 74.29699
Dim.18 0.7495784 1.7847106 76.08171
Dim.19 0.7310817 1.7406706 77.82238
Dim.20 0.6748913 1.6068840 79.42926
Dim.21 0.6462363 1.5386579 80.96792
Dim.22 0.6381290 1.5193548 82.48727
Dim.23 0.5740157 1.3667040 83.85398
Dim.24 0.5588069 1.3304926 85.18447
Dim.25 0.5501361 1.3098479 86.49432
Dim.26 0.5156254 1.2276796 87.72200
Dim.27 0.4873573 1.1603745 88.88237
Dim.28 0.4632245 1.1029156 89.98529
Dim.29 0.4501937 1.0718898 91.05718
Dim.30 0.4163010 0.9911929 92.04837
La proportion de variance expliquée par chaque valeur propre est donnée dans la deuxième colonne.
Une valeur propre > 1 indique que la composante principale (PC) concernée représente plus de variance par rapport à une seule variable d’origine, lorsque les données sont standardisées.
fviz_eig(res.pca, addlabels = TRUE)
fviz_pca_var(res.pca, col.var = "black", repel = T, alpha.var = 1)
fviz_cos2(res.pca, choice = "var", axes = 1:2)
Un cos2 élevé indique une bonne représentation de la variable sur les axes principaux en considération.
Un faible cos2 indique que la variable n’est pas parfaitement représentée par les axes principaux.
fviz_contrib(res.pca, choice = "var", axes = 1, top = 40)
fviz_contrib(res.pca, choice = "var", axes = 2, top = 40)
La ligne en pointillé rouge, sur le graphique ci-dessus, indique la contribution moyenne attendue.
var <- get_pca_var(res.pca)
res.pca$ind.sup
NULL
p <- fviz_pca_ind(res.pca, col.ind.sup = "blue", label =F)
p
fviz_nbclust(data, FUNcluster =factoextra::hcut, method = "gap_stat",hc_method = "average", hc_metric = "euclidean", stand = TRUE)
Clustering k = 1,2,..., K.max (= 10): .. done
Bootstrapping, b = 1,2,..., B (= 100) [one "." per sample]:
.................................................. 50
.................................................. 100
library(NbClust)
NbClust(data, distance = "euclidean", method = "average")
Warning: NaNs produced
[1] "Frey index : No clustering structure in this data set"
*** : The Hubert index is a graphical method of determining the number of clusters.
In the plot of Hubert index, we seek a significant knee that corresponds to a
significant increase of the value of the measure i.e the significant peak in Hubert
index second differences plot.
*** : The D index is a graphical method of determining the number of clusters.
In the plot of D index, we seek a significant knee (the significant peak in Dindex
second differences plot) that corresponds to a significant increase of the value of
the measure.
*******************************************************************
* Among all indices:
* 8 proposed 2 as the best number of clusters
* 2 proposed 3 as the best number of clusters
* 1 proposed 5 as the best number of clusters
* 10 proposed 6 as the best number of clusters
* 1 proposed 10 as the best number of clusters
* 1 proposed 15 as the best number of clusters
***** Conclusion *****
* According to the majority rule, the best number of clusters is 6
*******************************************************************
$All.index
KL CH Hartigan CCC Scott Marriot TrCovW TraceW Friedman Rubin Cindex DB
2 3.2766 3.5156 2.7523 23.3208 1169.675 1.263789e+83 39723.23 6225.061 1944.474 18.2281 0.4872 0.5304
3 1.1437 3.1432 3.1258 7.4468 1308.251 1.327959e+83 38717.97 6131.311 1990.127 18.5068 0.4848 0.5764
4 2.1907 3.1563 2.1992 4.6237 1423.996 1.249871e+83 37250.38 6026.079 2012.857 18.8300 0.4814 1.0014
5 0.0326 2.9297 11.0933 3.0574 1563.043 9.096803e+82 36585.58 5952.534 2059.232 19.0626 0.4796 0.9339
6 17.7039 4.6827 1.8340 3.1575 1733.564 5.132715e+82 31175.80 5601.468 2106.146 20.2574 0.5092 1.2135
7 0.1937 4.2245 3.9152 2.4651 1846.424 3.757775e+82 30723.11 5543.702 2146.265 20.4685 0.5091 1.1139
8 2.5318 4.2369 2.0840 2.1889 1958.871 2.645998e+82 29601.86 5422.388 2163.131 20.9264 0.5323 1.1787
9 1.9044 3.9892 1.4488 1.7080 2072.950 1.789264e+82 29109.91 5358.214 2191.129 21.1770 0.5304 1.1214
10 0.3096 3.7150 2.6600 1.0127 2131.510 1.601230e+82 28707.88 5313.714 2203.475 21.3544 0.5304 0.9958
11 1.5226 3.6399 1.9443 0.5684 2256.854 9.730556e+81 27896.85 5232.787 2236.226 21.6846 0.5269 1.0415
12 0.3673 3.5028 4.0553 -0.0648 2328.865 7.796142e+81 27271.81 5173.958 2249.323 21.9312 0.5252 1.0123
13 1.9631 3.6041 2.3395 -0.2482 2457.708 4.507689e+81 26049.83 5053.410 2280.927 22.4543 0.5410 1.0859
14 1.4957 3.5319 1.7184 -0.7808 2601.444 2.373216e+81 25662.22 4984.410 2326.307 22.7652 0.5408 1.1084
15 0.9180 3.4154 1.7854 -1.4354 2716.095 1.451040e+81 25289.57 4933.944 2372.608 22.9980 0.5407 1.0452
Silhouette Duda Pseudot2 Beale Ratkowsky Ball Ptbiserial Frey McClain Dunn Hubert SDindex Dindex
2 0.3384 0.9993 0.1189 0.0197 0.0806 3112.5304 0.2519 16.4275 0.0073 0.5496 0.0017 0.3251 5.6610
3 0.2759 0.9828 3.1084 0.5175 0.0975 2043.7704 0.3093 14.6894 0.0153 0.5496 0.0016 0.2682 5.6076
4 0.1888 1.0034 -0.5887 -0.0991 0.1079 1506.5197 0.3511 6.0721 0.0330 0.4380 0.0016 0.4176 5.5643
5 0.1718 0.9406 11.0558 1.8719 0.1082 1190.5068 0.3732 2.2771 0.0421 0.4380 0.0015 0.3625 5.5169
6 0.1593 1.0538 -0.4081 -1.3513 0.1400 933.5780 0.5326 1.3989 0.1382 0.4191 0.0015 0.4439 5.3817
7 0.1578 0.9767 3.9430 0.7078 0.1355 791.9574 0.5333 1.4344 0.1388 0.4191 0.0015 0.4032 5.3395
8 0.1416 1.0051 -0.8198 -0.1499 0.1362 677.7985 0.5648 1.1836 0.1715 0.4411 0.0015 0.4315 5.2878
9 0.1427 4.7068 0.0000 0.0000 0.1325 595.3571 0.5751 1.8994 0.1828 0.4411 0.0015 0.4092 5.2435
10 0.1357 0.9836 2.6823 0.4934 0.1284 531.3714 0.5751 1.6997 0.1829 0.4411 0.0015 0.3572 5.1916
11 0.1327 1.0047 -0.7484 -0.1394 0.1268 475.7079 0.5887 1.6161 0.2065 0.4411 0.0015 0.3819 5.1544
12 0.1266 0.9747 4.1048 0.7693 0.1246 431.1632 0.5949 1.4448 0.2186 0.4411 0.0014 0.3698 5.1121
13 0.1181 0.7710 2.0789 7.7438 0.1256 388.7239 0.6176 1.3088 0.2688 0.4588 0.0015 0.4141 5.0616
14 0.1168 1.1976 -0.6599 -3.9332 0.1247 356.0293 0.6182 1.7679 0.2703 0.4588 0.0014 0.4205 5.0271
15 0.1194 1.0083 -1.2624 -0.2427 0.1231 328.9296 0.6183 1.8724 0.2707 0.4588 0.0014 0.4060 4.9866
SDbw
2 0.4943
3 0.3274
4 0.6072
5 0.4846
6 0.5767
7 0.4865
8 0.5886
9 0.5227
10 0.3244
11 0.3953
12 0.3619
13 0.4086
14 0.4274
15 0.3911
$All.CriticalValues
CritValue_Duda CritValue_PseudoT2 Fvalue_Beale
2 0.9334 12.7635 1.0000
3 0.9333 12.7213 0.9959
4 0.9330 12.6367 1.0000
5 0.9329 12.5943 0.0006
6 0.7662 2.4416 1.0000
7 0.9313 12.1659 0.9221
8 0.9308 12.0357 1.0000
9 0.4959 0.0000 NaN
10 0.9307 11.9922 0.9976
11 0.9303 11.9048 1.0000
12 0.9302 11.8610 0.8588
13 0.7543 2.2797 0.0000
14 0.7025 1.6937 1.0000
15 0.9295 11.6848 1.0000
$Best.nc
KL CH Hartigan CCC Scott Marriot TrCovW TraceW Friedman Rubin Cindex
Number_clusters 6.0000 6.0000 6.0000 2.0000 6.0000 6.000000e+00 6.000 6.000 6.0000 6.0000 5.0000
Value_Index 17.7039 4.6827 9.2593 23.3208 170.5215 2.589147e+82 5409.783 293.299 46.9139 -0.9836 0.4796
DB Silhouette Duda PseudoT2 Beale Ratkowsky Ball PtBiserial Frey McClain Dunn Hubert
Number_clusters 2.0000 2.0000 2.0000 2.0000 2.0000 6.00 3.00 15.0000 NA 2.0000 2.0000 0
Value_Index 0.5304 0.3384 0.9993 0.1189 0.0197 0.14 1068.76 0.6183 NA 0.0073 0.5496 0
SDindex Dindex SDbw
Number_clusters 3.0000 0 10.0000
Value_Index 0.2682 0 0.3244
$Best.partition
[1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
[56] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 1 1 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5 1
[111] 1 1 5 1 1 1 1 1 1 5 1 1 1 1 1 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5 5 1 1 1 4 1 1 1 1 1 5 1 5 1 1
[166] 1 1 1 1 1 6 1 1 1 1 1 5 1 1 1 1 1
L’analyse recommande l’usage de 6 clusters
res.km <- kmeans(scale(data), 6, nstart = 25)
print(res.km)
K-means clustering with 6 clusters of sizes 11, 21, 34, 14, 62, 40
Cluster means:
LDS2 LDS3 LDS4 LDS5 LDS6 NSUB1 NSUB2 NSUB3 NSUB4
1 -0.6203445 -0.79746695 -1.5164796 0.09237398 0.57724912 0.205603410 -0.44852834 -0.84525990 -0.65308518
2 -0.6638071 -0.15199884 -0.4746705 -0.39218428 0.05831744 -0.554322920 0.71266170 0.18382864 -0.83018378
3 0.4695432 0.12775177 0.6304840 -0.06637771 -0.67226490 0.069649044 -0.52240360 -0.05662833 -0.01428008
4 -0.4964762 -0.48691154 -0.3369313 -0.02139187 -0.36534162 -0.006651875 0.16446039 -0.31928131 -0.08991160
5 0.3733359 0.25853931 0.1189410 0.33071141 0.19138523 0.249981755 0.01061035 0.05196514 0.45303846
6 -0.2849222 -0.03980309 0.0638898 -0.26820057 0.21328747 -0.209866657 0.11923378 0.21527301 -0.04315757
NSUB5 CF1 CF2 CF3 CF4 CF5 CF6 CF7 CF8
1 -0.84367066 0.5897871 0.8841169 0.33154068 0.2597260 -0.11454882 0.6025497 -0.55075123 -0.57599062
2 0.03941804 -0.5000497 -0.4369773 -0.34761538 0.3060182 -0.08055031 -0.7516341 0.02103564 0.08185913
3 0.34478182 0.9152935 -0.8838180 -0.31381123 0.4670197 0.69601559 0.9043726 0.81890499 0.68280146
4 -0.87405215 -1.5975615 0.2896245 0.48826899 -2.1445754 -1.61388297 -1.2299467 -1.15485649 -0.41475293
5 0.29240113 0.1235984 0.3322405 -0.02236198 0.3008850 0.31152925 0.1564986 0.20540282 0.07499353
6 -0.22905308 -0.3100958 0.1211850 0.22183085 -0.3448213 -0.43583471 -0.3519014 -0.46983096 -0.43603631
AFE1 AFE2 AFE4 AFE5 APF1 APF2 APF3 APF4 APF5
1 0.38266907 0.79651748 0.19656433 0.20773509 -0.09577480 -0.09320171 0.27451845 0.7763535 -0.0667380
2 -0.46897758 -0.25102655 0.48723614 -0.76846596 -0.54896209 -0.55176709 0.02720453 -0.1253904 0.3081483
3 0.72499763 -0.14114515 0.19201920 0.29422349 0.96198958 0.76168986 0.62890475 0.6478244 0.6113651
4 -0.84072811 0.31161917 -0.07938991 0.04570172 -0.96875663 -0.73687605 -1.38743109 -1.2005467 -1.1351639
5 0.06826188 0.03283729 0.09686473 0.12236267 0.05449256 0.02221997 0.28959662 0.1889893 0.2615898
6 -0.28681983 -0.12724449 -0.59542436 -0.10943023 -0.24854662 -0.10866252 -0.58761788 -0.5710600 -0.6712421
APF6 IEIP1 IEIP2 IEIP3 IEIP4 MOT1 MOT2 MOT3 MOT4 MOT5
1 0.22972852 0.1538282 -0.4132505 -0.2588015 1.2983792 0.076834942 -0.06603691 0.1467058 -0.9151228 0.5192468
2 -0.67985647 -0.9484638 0.3256272 -0.3213538 -0.5430886 -0.002086875 -0.26296418 0.1793071 -0.1185148 -0.4765518
3 1.06619000 0.4298393 0.4899732 0.9637278 -0.0664734 1.164476230 0.85000069 0.7467612 0.7934392 1.0603581
4 -1.01337097 -0.1701563 -1.1136451 -1.5254853 0.1452270 -0.951614984 -1.00759541 -1.7213479 -1.0333009 -1.3744029
5 0.05172371 0.2976211 0.4157524 0.2390945 -0.2106670 -0.177115098 0.14865749 0.1422888 0.1967680 0.1838033
6 -0.33800411 -0.3114806 -0.7284281 -0.4159641 0.2602741 -0.402245149 -0.44404495 -0.3873033 -0.3038794 -0.5977617
MOT6 MOT7 MOT8 MOT9 INTU1
1 0.4013871 0.43874264 0.45327911 0.3466459 0.1399222
2 -0.0547227 0.05260884 -0.09735702 0.1141177 -0.6279392
3 0.4980952 0.81063223 0.62586656 0.8378274 1.0277275
4 -0.1296064 -1.17123897 -0.86578207 -2.0600208 -1.8125058
5 0.2399809 0.23258646 0.38090373 0.1182432 0.1637102
6 -0.8316410 -0.78788664 -0.89290296 -0.3296624 -0.2017527
Clustering vector:
[1] 3 2 1 6 5 1 3 5 6 1 3 6 6 6 3 5 6 1 5 6 2 6 3 3 1 3 5 3 5 2 2 6 4 3 5 5 3 5 5 6 3 6 5 6 2 6 6 1 5 5 5 5 6 6 5
[56] 5 5 6 3 3 5 5 3 6 5 5 5 2 4 5 5 3 2 6 6 5 6 6 6 3 1 3 6 5 2 2 5 5 5 2 2 2 5 6 6 6 5 5 3 3 6 5 2 5 6 3 5 5 4 2
[111] 6 2 4 5 2 5 2 6 5 4 5 3 5 1 5 4 5 4 3 1 3 6 2 5 3 3 5 1 5 2 5 3 2 6 1 5 6 5 6 4 4 3 5 2 3 5 5 6 5 6 4 5 4 5 5
[166] 3 6 3 5 3 4 5 4 3 5 6 6 3 3 5 4 5
Within cluster sum of squares by cluster:
[1] 419.2851 612.0461 1058.3710 665.2583 1644.1213 1197.8989
(between_SS / total_SS = 26.4 %)
Available components:
[1] "cluster" "centers" "totss" "withinss" "tot.withinss" "betweenss" "size"
[8] "iter" "ifault"
clust6p <- fviz_cluster(res.km, data = scale(data),
geom = "point",
ellipse.type = "convex",
ggtheme = theme_bw()
)
ggplotly(clust6p)
NA
data$clust6 <- res.km$cluster
data$clust6 <- as.factor(data$clust6)
data6c <- data %>%
group_by(clust6) %>%
summarise_if(is.numeric, mean)
data6cw <- data6c %>%
pivot_longer(cols = -clust6, names_to = "Item", values_to = "Value")
data6cw
clust6mp <- ggbarplot(data6cw, x = "clust6", y = "Value", facet.by = "Item", fill = "clust6")
ggplotly(clust6mp, width = 800, height = 800)
NA
res.km2 <- kmeans(scale(data %>% select(-clust6)), 2, nstart = 25)
print(res.km2)
K-means clustering with 2 clusters of sizes 69, 113
Cluster means:
LDS2 LDS3 LDS4 LDS5 LDS6 NSUB1 NSUB2 NSUB3 NSUB4 NSUB5
1 -0.4788077 -0.16364798 -0.203983 -0.2833648 0.06025638 -0.2410100 0.2597997 0.12914277 -0.1712230 -0.2666865
2 0.2923693 0.09992664 0.124556 0.1730280 -0.03679372 0.1471654 -0.1586388 -0.07885709 0.1045521 0.1628440
CF1 CF2 CF3 CF4 CF5 CF6 CF7 CF8 AFE1 AFE2
1 -0.6591094 -0.013844243 0.2202409 -0.5961766 -0.6464037 -0.6565658 -0.5068674 -0.3129629 -0.5142342 -0.09642129
2 0.4024650 0.008453564 -0.1344834 0.3640371 0.3947067 0.4009118 0.3095031 0.1911012 0.3140014 0.05887672
AFE4 AFE5 APF1 APF2 APF3 APF4 APF5 APF6 IEIP1 IEIP2
1 -0.2536010 -0.2001750 -0.4964878 -0.3646461 -0.6422635 -0.6380877 -0.6062483 -0.5469340 -0.4105945 -0.5381816
2 0.1548537 0.1222308 0.3031651 0.2226600 0.3921786 0.3896287 0.3701870 0.3339686 0.2507170 0.3286241
IEIP3 IEIP4 MOT1 MOT2 MOT3 MOT4 MOT5 MOT6 MOT7 MOT8
1 -0.5906006 0.07083764 -0.4455932 -0.5249096 -0.6034073 -0.3822746 -0.7576182 -0.5723969 -0.6986021 -0.7223165
2 0.3606322 -0.04325484 0.2720879 0.3205200 0.3684522 0.2334243 0.4626164 0.3495167 0.4265800 0.4410605
MOT9 INTU1
1 -0.6243109 -0.6637673
2 0.3812164 0.4053092
Clustering vector:
[1] 2 1 2 1 2 2 2 2 1 2 2 1 1 1 2 2 1 2 2 1 1 1 2 2 2 2 2 2 2 2 2 1 1 2 2 2 2 2 2 1 2 1 2 1 1 1 1 2 2 2 1 2 1 1 2
[56] 2 2 1 2 2 2 2 2 2 2 2 2 1 1 2 2 2 2 1 1 2 1 1 1 2 2 2 1 2 1 2 2 2 2 1 2 1 2 1 1 1 2 2 2 2 1 2 1 2 1 2 2 2 1 1
[111] 1 1 1 2 1 2 1 1 2 1 2 2 2 2 2 1 2 1 2 2 2 1 1 2 2 2 2 2 2 2 2 2 1 1 1 2 1 2 1 1 1 2 2 2 2 2 2 1 2 1 1 2 1 2 2
[166] 2 1 2 2 2 1 2 1 2 2 1 1 2 2 2 1 2
Within cluster sum of squares by cluster:
[1] 2663.731 3888.215
(between_SS / total_SS = 13.8 %)
Available components:
[1] "cluster" "centers" "totss" "withinss" "tot.withinss" "betweenss" "size"
[8] "iter" "ifault"
clust2p <- fviz_cluster(res.km2, data = scale(data %>% select(-clust6)),
geom = "point",
ellipse.type = "convex",
ggtheme = theme_bw()
)
ggplotly(clust2p, width = 800, height = 800)
NA
data$clust2 <- res.km2$cluster
data$clust2 <- as.factor(data$clust2)
data2c <- data %>%
group_by(clust2) %>%
summarise_if(is.numeric, mean)
data2cw <- data2c %>%
pivot_longer(cols = -clust2, names_to = "Item", values_to = "Value")
data2cw
clust2mp <- ggbarplot(data2cw, x = "clust2", y = "Value", facet.by = "Item", fill = "clust2")
ggplotly(clust2mp, width = 800, height = 800)
NA